<template>
<div class='app-container'>
 <!-- <h1>ddd</h1> -->
  <mt-header fixed title='一分地'>
       <span @click='back()' slot="left"  v-show='flag'> 
    <mt-button icon="back">返回</mt-button>
  </span>     
  </mt-header>    

  <transition>
  <router-view></router-view>
  </transition>
  
  <nav class="mui-bar mui-bar-tab">
			<router-link class="mui-tab-item1" to="/home">
				<span class="mui-icon mui-icon-home"></span>
				<span class="mui-tab-label">首页</span>
			</router-link>
			<router-link class="mui-tab-item1" to="/member">
				<span class="mui-icon mui-icon-contact"></span>
				<span class="mui-tab-label">会员</span>
			</router-link>
			<router-link class="mui-tab-item1" to="/shopcar">
				<span class="mui-icon mui-icon-extra mui-icon-extra-cart"><span class="mui-badge">{{$store.getters. totalcount}}</span></span>
				<span class="mui-tab-label">购物车</span>
			</router-link>
			<router-link class="mui-tab-item1" to="/search">
				<span class="mui-icon mui-icon-search"></span>
				<span class="mui-tab-label">搜索</span>
			</router-link>
		</nav>
     
</div>
 
</template>
<script>
    export default{
        data(){
            return{ 
                flag:false              
            }
        },
        created(){
            // 由于页面再次刷新时，path并没有改变，所以检测不到url地址的变化，所以在初始化时先判断一次
          /*   if(this.$route.path=='/home'){
                this.flag=false;
            }else{
                this.flag=true;
            } */
           this.flag = this.$route.path==='/home'?false:true;
        },     
        methods:{
        back(){
                this.$router.go(-1);
                // this.$router.back();              
            }
        },
        watch:{ //监测路由地址的变化
            '$route.path':function(newVal,oldVal){
                console.log(newVal);
                if(newVal=='/home'){
                   this.flag=false;
                }else{
                    this.flag=true;
                }
            }
        }
    }
</script>
<style scoped lang='scss'>
.app-container{
	padding-top:40px;
	padding-bottom:50px;
	overflow-x:hidden;
    .mint-header{
        z-index:99;
    }
}
.btn{
    position: absolute;
    left: 0;
    border:none;
    top:5px;
    z-index: 1000;
    background-color:transparent;
    color:#fff;
    display:none;
}
.v-enter{ //动画进入时，从右往原位置移动
	opacity: 0;
	transform:translateX(100%);
}
.v-leave-to{// 动画离开时，从原位置往左
	opacity: 0;
	transform:translateX(-100%);
		position:absolute; // 当动画离开时绝对定位，下面即下一页元素则会跑到最上面

}
.v-enter-active,.v-leave-active{
	transition:all 2s ease;
}
// 更改样式---解决图片列表导航滑动时tabbar无效的问题
.mui-bar-tab .mui-tab-item1.mui-active {
    color: #007aff;
}
.mui-bar-tab .mui-tab-item1 {
    display: table-cell;
    overflow: hidden;
    width: 1%;
    height: 50px;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #929292;
}
.mui-bar-tab .mui-tab-item1 .mui-icon {
    top: 3px;
    width: 24px;
    height: 24px;
    padding-top: 0;
    padding-bottom: 0;
}
.mui-bar-tab .mui-tab-item1 .mui-icon~.mui-tab-label {
    font-size: 11px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}
</style>

